//
//  SDAppUtils.m
//  SKinDiary
//
//  Created by pcyang on 16/6/26.
//  Copyright © 2016年 tencent. All rights reserved.
//

#import "SDAppUtils.h"

static float currentVersion = 0;

@implementation SDAppUtils
+ (float)currentIOSVersion
{
    if( currentVersion < 0.5 )
        currentVersion = [[UIDevice currentDevice].systemVersion floatValue];
    
    return currentVersion;
}

+ (NSString *)getAppVersion
{
    NSString *appVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
    NSMutableArray *component = [NSMutableArray arrayWithArray:[appVersion componentsSeparatedByString:@"."]];
    while (component.count < 3) {
        [component addObject:@"0"];
    }
    while (component.count > 3) {
        [component removeLastObject];
    }
    appVersion = [component componentsJoinedByString:@"."];
    return appVersion;
}

+ (NSString *)getAppBuildVersion
{
    NSString *buildVersion = [SDAppUtils getAppVersion];
    buildVersion = [buildVersion stringByAppendingFormat:@".%@", [SDAppUtils getAppBuildNumber]];
    return buildVersion;
}

+ (NSString *)getAppBuildNumber {
    return [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];
}

+ (NSString *)getAppVersionCode {
    return [NSString stringWithFormat:@"%d", kAppVersionCode];
}

+ (NSString *)bundleID {
    return [[NSBundle mainBundle] bundleIdentifier];
}

@end
